// SPDX-FileCopyrightText: 2023-2025 Sangfor Technologies Inc.
// SPDX-License-Identifier: Mulan PSL v2
package com.geniusai.aip.auth.exception;

import com.geniusai.aip.feature.common.web.exceptions.rest.RestErrorInfo;
import org.springframework.http.HttpStatus;
import static com.geniusai.aip.feature.common.utils.constants.Constants.BizType.BIZ_AUTH;

/**
 * @author hml14563
 * @date 2021/3/19
 */
public enum AuthLoginExceptionEnum implements RestErrorInfo {

    /**
     * 错误类型
     */
    INPUT_FORMAT_ERROR("A0001", "输入的参数格式要求不匹配", HttpStatus.BAD_REQUEST),
    MISMATCHED_INPUT_TYPE("A0002", "输入参数类型不匹配", HttpStatus.BAD_REQUEST),
    DUPLICATED_NAME_ERROR("A0003", "用户名已存在,请重新输入用户名", HttpStatus.BAD_REQUEST),
    PASSWORD_ERROR("A0004", "输入原密码错误", HttpStatus.BAD_REQUEST),
    SAME_PASSWORD_ERROR("A0005", "密码和原密码一样，请重试输入", HttpStatus.BAD_REQUEST),
    USER_NOT_FOUND("A0006", "用户或密码错误", HttpStatus.BAD_REQUEST),
    EMPTY_VALIDATION_CODE("A0007", "验证码不能为空", HttpStatus.BAD_REQUEST),
    VALIDATION_CODE_ERROR("A0008", "验证码错误", HttpStatus.BAD_REQUEST),
    VALIDATION_CODE_EXPIRED("A0009", "验证码超时", HttpStatus.BAD_REQUEST),
    INVALID_SESSION("A0010", "无效的session", HttpStatus.UNAUTHORIZED),
    USERNAME_NOT_FOUND("A0011", "没有找到对应的用户名", HttpStatus.BAD_REQUEST),
    USERID_INVALID_ERROR("A0012", "根据ID没有找到指定用户异常", HttpStatus.BAD_REQUEST),
    PASSWORD_FORMAT_ERROR("A0013", "密码格式错误", HttpStatus.BAD_REQUEST),
    EMPTY_USERNAME("A0014", "没有用户名信息", HttpStatus.BAD_REQUEST),
    USERNAME_FORMAT_ERROR("A0015", "用户名不符合", HttpStatus.BAD_REQUEST),
    FAIL_CONNECT_WEBSERVICE("A0016", "无法获取对应项目个数", HttpStatus.BAD_REQUEST),
    CREATE_PROFILE_ERROR("A0017", "创建profile失败", HttpStatus.BAD_REQUEST),
    DELETE_PROFILE_ERROR("A0018", "删除profile失败", HttpStatus.BAD_REQUEST),
    EDIT_PROFILE_ERROR("A0019", "修改profile对象失败", HttpStatus.BAD_REQUEST),
    FAIL_CONNECT_STUDIO_SERVICE("A0020", "无法获取codeStudio数目", HttpStatus.BAD_REQUEST),
    FAIL_CONNECT_TRAINING_SERVICE("A0021", "无法连接traning-service服务", HttpStatus.BAD_REQUEST),
    UNSUPPORT_OBJECT_STORAGE_TYPE("A0022", "不支持出Minio、EDS以外的存储", HttpStatus.BAD_REQUEST),
    FAIL_CREATE_MINIO_USER("A0023", "创建对象存储用户失败", HttpStatus.BAD_REQUEST),
    FAIL_DELETE_MINIO_USER("A0024", "删除对象存储用户失败", HttpStatus.BAD_REQUEST),
    RESOURCE_EXCEEDED_ERROR("A0025", "用户资源超配，请重新配置", HttpStatus.BAD_REQUEST),
    DELETE_USERID_NOTEBOOKS_RECORDS_ERROR("A0026", "删除用户notebooks数据库记录失败", HttpStatus.BAD_REQUEST),
    DELETE_USERID_IMAGES_RECORDS_ERROR("A0027", "删除用户images数据库记录失败", HttpStatus.BAD_REQUEST),
    EDS_LOGIN_FAILED("A0028", "登录EDS失败", HttpStatus.BAD_REQUEST),
    EDS_CREATE_KEYS_FAILED("A0029", "创建accessKey和secreteKey失败", HttpStatus.BAD_REQUEST),
    EDS_VERIFY_FAILED("A0030", "EDS身份验证失败", HttpStatus.BAD_REQUEST),
    EDS_DECRYPT_KEYS_FAILED("A0031", "解密accessKey和secreteKey失败", HttpStatus.BAD_REQUEST),
    EDS_CREATE_USERS_FAILED("A0032", "创建edsUsers失败", HttpStatus.BAD_REQUEST),
    EDS_CREATE_BUCKETS_FAILED("A0033", "创建edsBuckets失败", HttpStatus.BAD_REQUEST),
    EDS_DELETE_BUCKETS_FAILED("A0034", "删除edsBuckets失败", HttpStatus.BAD_REQUEST),
    EDS_DELETE_USERS_FAILED("A0035", "删除edsUsers失败", HttpStatus.BAD_REQUEST),
    EDS_MODE_ERROR("A0036", "配置文件中spring.eds-service.mode配置错误", HttpStatus.NOT_FOUND),
    EDS_MODE_ERROR_DELETE_FAILED("A0037", "配置文件中spring.eds-service.mode配置错误,导致删除用户失败,", HttpStatus.NOT_FOUND),
    DELETE_PROJECT_ERROR("A0038", "删除用户项目失败", HttpStatus.BAD_REQUEST),
    DELETE_DATASOURCE_ERROR("A0039", "删除数据源失败", HttpStatus.BAD_REQUEST),
    ADD_INITIALIMAGE_ERROR("A0040", "新用戶添加基础镜像失败", HttpStatus.BAD_REQUEST),
    CUSTOM_VGPU_ERROR("A0040", "自定义vGpu失败", HttpStatus.BAD_REQUEST),
    CREATE_ENVOYFILTER_ERROR("A0041", "创建envoyfilter失败", HttpStatus.BAD_REQUEST),
    DELETE_ENVOYFILTER_ERROR("A0042", "删除envoyfilter失败", HttpStatus.BAD_REQUEST),
    CREATE_DATASPACE_ERROR("A0043","创建数据空间异常",HttpStatus.BAD_REQUEST),
    COOKIE_NEEDED("A0044","cookie缺失" ,HttpStatus.BAD_REQUEST ),;

    public final static String TYPE = BIZ_AUTH;

    String errorCode;
    String errMsg;
    HttpStatus httpStatus;

    AuthLoginExceptionEnum(String errorCode, String errMsg, HttpStatus httpStatus) {
        this.errMsg = errMsg;
        this.errorCode = errorCode;
        this.httpStatus = httpStatus;
    }

    @Override
    public String getCode() {
        return this.errorCode;
    }

    @Override
    public String getMessage() {
        return this.errMsg;
    }

    @Override
    public String getBizType() {
        return TYPE;
    }

    @Override
    public HttpStatus getResponseStatus() {
        return this.httpStatus;
    }
}
